package com.huangpuweb.api.service.imp;

import com.huangpuweb.api.model.BmxModel;
import com.huangpuweb.api.model.SanitationInfo;
import com.huangpuweb.api.model.SanitationInfoRowMapper;
import com.huangpuweb.api.service.SanitationService;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;


import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

@Service
public class SanitationServiceImpl extends BaseSanitationServiceImp implements SanitationService {
    @Override
    public void insert(String lng, String lat, Integer id) {
        String sql="update  b_mx_ztsjyljgtjb set lng=?,lat=? where id=?";
        update(sql, new Object[]{lng, lat,id});
    }

    @Override
    public List<BmxModel> getList() {
        String sql="select id,lng,lat,jgdz from b_mx_ztsjyljgtjb";
        return getEntryList(sql, new RowMapper<BmxModel>() {
            @Override
            public BmxModel mapRow(ResultSet rs, int rowNum) throws SQLException {
                BmxModel bmxModel=new BmxModel();
                bmxModel.setId(rs.getInt("id"));
                bmxModel.setJgdz(rs.getString("jgdz"));
                bmxModel.setLat(rs.getString("lat"));
                bmxModel.setLng(rs.getString("lng"));
                return bmxModel;
            }
        },new Object[]{});
    }

    @Override
    public List<SanitationInfo> getFxdkList() {
        String sql="select * from b_st_fxd_fxdk ";
        return getEntryList(sql, new SanitationInfoRowMapper(),new Object[]{});
    }
}
